<template>
  <div class="box">
    <div class="title">
      <span>{{title}}</span>
    </div>
    <scroller lock-y class="content" ref="scrollBar" :scrollbar-x="false">
      <div class="card-box">
        <v-qstragerycard 
          :key="idx"
          v-for="(obj, idx) in item"
          :item="obj"
          v-on:selected="selectedQstragery(idx)">
        </v-qstragerycard>
      </div>
    </scroller>
  </div>
</template>

<script>
import { Scroller } from 'vux'

export default {
  name: 'qstragery-list',
  components: {
    Scroller
  },
  props: {
    item: {
      default: [],
      type: Array
    },
    title: {
      default: '',
      type: String
    }
  },
  watch: {
    item: function(val) {
      this.$nextTick(() => {
        this.$refs.scrollBar.reset({left: 0})
      })
    }
  },
  methods: {
    selectedQstragery (val) {
      this.$emit('choice', val)
    }
  },
  data () {
    return {
      globalRem: 1
    }
  },
  mounted () {

  }
}
</script>

<style lang="less" scoped>
.box {
  position: relative;
  padding-top: 0.5rem;
  display: -webkit-box;
  display: flex;
  flex-direction: column;
  .title {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex: 1;
    span {
      height: 1.8rem;
      width: 6.7rem;
      display: flex;
      align-items: center;
      letter-spacing: 2px;
      @media screen and (max-width:375px) and (min-width:321px) {
        height: 2.1rem;
        width: 7.9rem;
        font-size: 1.4rem;
        padding-left: 0.9rem;
      }
      @media screen and (min-width: 376px){
        height: 2.3rem;
        padding-left: 1rem;
        width: 8.7rem;
        font-size: 1.4rem;
      }
      border: 1px solid rgb(101, 128, 255);
      padding-left: 0.8rem;
      color: rgb(101, 128, 255);
      font-size: 1rem;
      border-radius: 0 25px 25px 0;
      width: 6.7rem;
      height: 1.8rem;
      line-height: 1.8rem;
    }
    sub {
      align-items: center;
      display: flex;
      justify-content: center;
      margin-right: 1rem;
    }
  }
  .content {
    display: -webkit-box;
    width: 100%;
    position: relative;
    overflow-x: hidden;
    min-height: 11.2em;
    tansform:translateZ(0);
    flex-direction: row;
    @media screen and (max-width:375px) and (min-width:321px) { 
      min-height: 12.2em;
    }
    @media screen and (min-width: 376px){
      min-height: 13.2em;
    }
    .card-box {
      display: flex;
      padding: 0 1.8rem;
      padding-bottom: 0.8em;
    }
  }
}
.content::-webkit-scrollbar  {
  height: 1px;
}
.active {
  background-image: linear-gradient(-180deg, #7792FF 0%, #4F6AFF 100%);
}
</style>